package o;

import android.content.Context;
import android.text.format.DateUtils;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
import o.bcg.f;
import o.bcg.h;

public class bei {
    public static String ॱ(Context context, String str) {
        try {
            long parseLong = Long.parseLong(str);
            long currentTimeMillis = System.currentTimeMillis();
            long j = currentTimeMillis - parseLong;
            if (j < 60000) {
                return context.getResources().getString(h.ॱʽ);
            }
            if (j >= 3600000) {
                return ˎ(context, parseLong, currentTimeMillis);
            }
            int intValue = Long.valueOf(j / 60000).intValue();
            return context.getResources().getQuantityString(f.ˏ, intValue, new Object[]{Integer.valueOf(intValue)});
        } catch (Throwable e) {
            bcb.ˋ.ˊ("CommentTimeUtil", "get time error", e);
            return ˋ(context, str);
        }
    }

    private static String ˎ(Context context, long j, long j2) {
        int i;
        int i2 = 0;
        Calendar instance = Calendar.getInstance();
        instance.setTimeInMillis(j);
        Calendar instance2 = Calendar.getInstance();
        instance2.setTimeInMillis(j2);
        if ((instance.get(1) == instance2.get(1) ? 1 : 0) == 0 || instance.get(2) != instance2.get(2)) {
            i = 0;
        } else {
            i = 1;
        }
        int i3 = instance.get(5);
        int i4 = instance2.get(5);
        if (i != 0 && i3 == i4) {
            i2 = 1;
        }
        if (i2 != 0) {
            return DateUtils.formatDateTime(context, j, 1);
        }
        if (ॱ(instance, instance2)) {
            return context.getResources().getString(h.ॱͺ);
        }
        return DateUtils.formatDateTime(context, j, 131076);
    }

    private static String ˋ(Context context, String str) {
        if (dof.ॱ(str)) {
            return "";
        }
        try {
            return DateUtils.formatDateTime(context, TimeUnit.SECONDS.toMillis(Long.parseLong(str)), 131076);
        } catch (Throwable e) {
            bcb.ˋ.ˊ("CommentTimeUtil", "getDefaultShowTime time error", e);
            return "";
        }
    }

    private static boolean ॱ(Calendar calendar, Calendar calendar2) {
        ॱ(calendar, 11, 12, 13, 14);
        ॱ(calendar2, 11, 12, 13, 14);
        calendar2.add(5, -1);
        return calendar.getTimeInMillis() == calendar2.getTimeInMillis();
    }

    private static void ॱ(Calendar calendar, int... iArr) {
        for (int i : iArr) {
            calendar.set(i, 0);
        }
    }
}
